<?php
switch ($_REQUEST['sAction'])
{
	case 'client-groupchange':
		$iResult = ClientHandler::changeGroup($_REQUEST['iClientgroup'], $_REQUEST['sName']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-groupdelete':
		$iResult = ClientHandler::delGroup($_REQUEST['iClientgroup']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list');
			exit();
		}
		break;
	case 'client-groupadd':
		$iResult = ClientHandler::addGroup($_REQUEST['sName']);
		if ($iResult > 0) {
			header('Location: index.php?sView=client-list&iClientgroup='.$iResult);
			exit();
		}
		break;
	case 'client-add':
		$iResult = ClientHandler::addClient($_REQUEST['iClientgroup'], $_REQUEST['sName'], $_REQUEST['sSerial']);
		if ($iResult > 0) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-change':
		$iResult = ClientHandler::changeClient($_REQUEST['iClientgroup'], $_REQUEST['iClient'], $_REQUEST['sName'], $_REQUEST['sSerial'], $_REQUEST['iNewClientgroup'], $_REQUEST['bUpdateWork']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-delete':
		$iResult = ClientHandler::delClient($_REQUEST['iClientgroup'], $_REQUEST['iClient'], $_REQUEST['sName'], $_REQUEST['sSerial']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-useradd':
		$iResult = ClientHandler::addUser($_REQUEST['iClientgroup'], $_REQUEST['iUser'], $_REQUEST['bAdmin']);
		if ($iResult > 0) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-userchange':
		$iResult = ClientHandler::changeUser($_REQUEST['iClientgroup'], $_REQUEST['iUser'], $_REQUEST['bAdmin']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
	case 'client-userdelete':
		$iResult = ClientHandler::delUser($_REQUEST['iClientgroup'], $_REQUEST['iUser']);
		if ($iResult == 1) {
			header('Location: index.php?sView=client-list&iClientgroup='.$_REQUEST['iClientgroup']);
			exit();
		}
		break;
}
?>
